<!doctype html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>{$list.sys_title}{$list.version}</title>
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />

        {load href="__XADMIN__/css/font.css" /}
        {load href="__XADMIN__/css/xadmin.css" /}
        {load href="__STATIC__/mayi/css/studentSearch.css" /}
        {load href="__XADMIN__/js/jquery.min.js" /}
        {load href="__XADMIN__/lib/layui/layui.js" /}
        {load href="__XADMIN__/js/xadmin.js" /}
        {load href="__XADMIN__/js/cookie.js" /}
        {load href="__XADMIN__/js/md5.min.js" /}
        {load href="__STATIC__/echarts/echarts.js" /}

        <meta name="keywords" content="{php}echo $list['keywords']{/php}">
        <meta name="description" content="{php}echo $list['description']{/php}">
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
        <script>
            // 是否开启刷新记忆tab功能
            var is_remember = false;
        </script>
        <!-- // 百度统计代码  -->
        <script>
          var _hmt = _hmt || [];
          (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?6f65eecea5e089dae94d6b9cffec3623";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
          })();
        </script>
    </head>
    <body>
        <!-- 顶部开始 -->
        <div class="container">
            <div class="logo">
                <a href="/studentSearchChengji/index/index">{$list['sys_title']}</a></div>
            <ul class="layui-nav right" lay-filter="">
                <li class="layui-nav-item">
                    <a href="javascript:;">{$list.banjiTitle}&nbsp;&nbsp;{$list.xingming}</a>
                    <dl class="layui-nav-child">
                      <!-- 二级菜单 -->
                      <dd>
                        <!-- <a onclick="layer.msg('修改密码，请下载后本地测试。')">
                            修改密码</a> -->
                        <a onclick="xadmin.open('修改密码','/studentSearchChengji/index/editpassword','400','250')">
                            修改密码</a>
                          </dd>
                      <dd>
                        <a onclick="xadmin.open('系统帮助','https://www.kancloud.cn/llblax/abcd/789222')">
                            系统帮助</a></dd>
                      <dd>
                        <a href="/login">切换帐号</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item to-index">
                    <a href="/login">退了</a></li>
            </ul>
        </div>
        {if (session('student.password') == 123) }
          <blockquote class="layui-elem-quote" style="margin-top: 10px;color: red;">
            您现在使用的是默认密码，为了您的信息不被漏，请及时修改密码。
          </blockquote>
        {/if}
        <div class="myrow" style="height: 350px;">
          <div class="x-body" style="text-align: left;">
          <div class="layui-collapse">
            <div class="layui-colla-item">
              <h2 class="layui-colla-title">筛选</h2>
              <div class="layui-colla-content layui-hidden" style="margin: 2;padding: 2;">
                <div class="layui-row">
                  <form class="layui-form layui-form-pane" id="search" lay-filter="search">

                    <div class="layui-form-item">
                      <label for="searchval" class="layui-form-label">
                        关键字
                      </label>
                      <div class="layui-input-block">
                        <input type="text" id="searchval" name="searchval" autocomplete="off" class="layui-input">
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label for="xueqi_id" class="layui-form-label" style="height: 100%">学期</label>
                      <div class="layui-input-block">
                        <input type="radio" name="xueqi_id" title="无" value="" lay-skin="primary" checked="true">
                        {php} $category = categoryChildren(108);{/php}
                        {volist name="category" id="vo"}
                        <input type="radio" name="xueqi_id" title="{$vo.title}" value="{$vo.id}" lay-skin="primary">
                        {/volist}
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label for="category_id" class="layui-form-label" style="height: 100%">考试类型</label>
                      <div class="layui-input-block">
                        {php} $category = categoryChildren(109);{/php}
                        {volist name="category" id="vo"}
                          <input type="checkbox" name="category_id[]" title="{$vo.title}" value="{$vo.id}" lay-skin="primary">
                        {/volist}
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <div class="layui-inline">
                        <label for="title" class="layui-form-label">
                          <span class="x-red">*</span>考试时间
                        </label>
                        <div class="layui-input-inline">
                          <input type="text" class="layui-input" id="bfdate" name="bfdate" placeholder="起始：默认一年前的今天" value="{$list.data.bfdate|default=''}" autocomplete="off" lay-filter="riqi">
                        </div>
                        <div class="layui-input-inline">
                          <input type="text" class="layui-input" id="enddate" name="enddate" placeholder="结束：默认明天" value="{$list.data.enddate|default=''}" autocomplete="off" lay-filter="riqi">
                        </div>
                      </div>
                    </div>
                    <input type="hidden" name='student_id' id='student_id' value="{$list.student_id}">
                    <div class="layui-form-item" style="text-align: right;">
                        <input type="hidden" class="layui-btn" id="srcsubmit" lay-filter="srcsubmit" lay-submit="">
                    </div>
                  </form>
                </div>
              </div>
            </div>
          </div>
          <table id="tabledemo" lay-filter="mytable" lay-size="sm"></table>
        </div>
        <div class="myrow" style="height: 50px;">
          {volist name="$list.sbj" id="vo"}
            <div class="layui-col-xs6" style="width:100%; height:400px; margin-top: 45px; margin-bottom: 45px;" id="{$vo.lieming}"></div>
          {/volist}
        </div>
        <hr class="hr20" >
        <div class="myrow" style="height: 50px;">
            <div class="layui-col-md12">
                <blockquote class="layui-elem-quote layui-quote-nm">
                    感谢{$list.thinks}提供技术支持。<br>
                    本系统由{$list.danwei}负责管理
                </blockquote>
            </div>
        </div>
    </body>
    <script type="text/html" id="barDemo">
      <a class="layui-btn-xs" lay-event="detail" title="查看"><i class="layui-icon layui-icon-search"></i></a>
    </script>
    <script type="text/javascript">
        //config的设置是全局的
  layui.config({
      base: "__XADMIN__/js/" //假设这是你存放拓展模块的根目录
    });

  layui.use(['element','table','cjgl','form', 'laydate'], function(){
    var element = layui.element
        table = layui.table
        cjgl = layui.cjgl
        form = layui.form
        laydate = layui.laydate

    // 设置表格初始变量
    options = {
      elem: '#tabledemo',
      toolbar: '#toolbarDemo',
      url:"/tools/onestudentchengji/oldcj",
      method:"POST",   //数据接口
      page: true, //开启分页
      loading:true,
      autoSort:true,
      id:'mytable',
      defaultToolbar:[],
      limits:[10,25,50,75,100],
      limit:10,
      toolbar:false,
    };

    // 设置列
    options.cols=[[ //表头
      {field:'id',type:'numbers',sort:true,width:50,title:'序号'}
      ,{field: 'id', title: '操作',toolbar: '#barDemo',minWidth:10}
      ,{field: 'kaoshiTitle', title: '考试标题',sort: true},
      {field: 'enddate', title: '考试时间',sort: true,templet:function(d){
        var date;
        date = d.enddate.split('-');
        endate = date[1] + '-' + date[2];
        endate = d.bfdate + '～' + endate;
        return endate;
      }},
      {field: 'category_id', title: '考试类型',sort: true},
    ]];

    options.where = form.val("search");

    var xk = '<?php echo json_encode($list["sbj"]);?>';
    xk = eval(decodeURIComponent(xk));
    for(x in xk)
    {
      options.cols[0].push({field:xk[x].lieming, title: xk[x].title , minWidth:100,sort: true});
    }
    options.cols[0].push({field: 'avg', title: '平均分', minWidth:100,sort: true});
    options.cols[0].push({field: 'sum', title: '总分', minWidth:100,sort: true});

    chengjiTable = table.render(options);  //获取数据并渲染

    for(x in xk)
    {
      getDefenlv(xk[x].id,xk[x].lieming,xk[x].title);
    }

    //监听行工具条
    table.on('tool(mytable)', function(obj){
      var data = obj.data; //获得当前行数据
      var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
      var tr = obj.tr; //获得当前行 tr 的DOM对象
      switch(layEvent){
        case 'detail':// 查看
          cjgl.add(obj.data.kaoshiTitle + '考试成绩','/studentSearchChengji/index/read/' + obj.data.kaohao_id,'','',true);
          break;
      };
    });

    // 监听单选
    form.on('radio', function(data){
      $("#srcsubmit").click();
    });

    // 监听复选框
    form.on('checkbox', function(data){
      $("#srcsubmit").click();
      return true;
    });

    // 监听表单提交
    form.on('submit(srcsubmit)', function(data){
      for(x in xk)
      {
        getDefenlv(xk[x].id,xk[x].lieming,xk[x].title);
      }
      tablereload();
      return false;
    });

    // 禁止使用回车提交表单
    $('#searchval').on("keydown", function(e){
      var e = e || window.event;
      if(e.keyCode == 13){
         $("#srcsubmit").click();
         return false;
      }
      return true;
    })


    //开始时间
    laydate.render({
      elem: '#bfdate'
      ,type: 'datetime'
      ,trigger: 'click' //采用click弹出
      ,format: 'yyyy-M-d' //可任意组合
      ,done: function(value, date, endDate){
        form.val("search",{
          "bfdate" : value,
        });
        $("#srcsubmit").click();
      }
    });
    //结束时间
    laydate.render({
      elem: '#enddate'
      ,type: 'datetime'
      ,trigger: 'click' //采用click弹出
      ,format: 'yyyy-M-d' //可任意组合
      ,done: function(value, date, endDate){
        form.val("search",{
          "enddate" : value,
        });
        $("#srcsubmit").click();
      }
    });


    // 表格重载
    function tablereload()
    {
      options.where = form.val("search");
      chengjiTable = table.render(options);  //获取数据并渲染
    }

    // 条形统计图--平均分
   function getDefenlv(sbjid, sbjlieming, sbjtitle){
    var id = sbjlieming;
    var url = '/tools/onestudentchengji/xkold';
    var val = form.val('search');
    val.subject_id = sbjid;
    var title = sbjtitle;
    createZhexian(id, url, val, title);
  }


  });

  /**
  * 异步获取图表中的数据
  *
  * @access public
  * @param id 要添加数据的div
  * @param url 异步地址
  * @param val 异步时携带的参数
  * @param val 图表标题
  * @return array 返回类型
  */
  function createZhexian(id, url, val, title)
  {
    var myZhexian = echarts.init(document.getElementById(id));
    $.post(url,val).done(function (data) {
      myZhexian.setOption({
        title: {
          text: title
        },
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: data.legend
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: data.xAxis,
        },
        yAxis: {
          type: 'value'
        },
        series: data.series,
      });
    });
  }


    </script>
</html>
